//package com.itcast.cheetah.rabbitmq.order;
//
//import com.itcast.cheetah.rabbitmq.config.DelayQueueRabbitConfig;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * @className: SendMessageController
// * @description: 发送者
// * @author: cheetah
// * @date: 2022/2/7 17:40
// * @Version: 1.0
// */
//@RestController
//@RequestMapping("/order")
//public class OrderSendMessageController {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @GetMapping("/sendMessage")
//    public String sendMessage(){
//
//        String delayTime = "10000";
//        //将消息携带路由键值
//        rabbitTemplate.convertAndSend(DelayQueueRabbitConfig.ORDER_EXCHANGE, DelayQueueRabbitConfig.ORDER_ROUTING_KEY,
//                "发送消息！",message->{
//            message.getMessageProperties().setExpiration(delayTime);
//            return message;
//        });
//        return "ok";
//    }
//
//    @GetMapping("/sendManyMessage")
//    public String sendManyMessage(){
//
//        send("延迟消息睡10秒",10000+"");
//        send("延迟消息睡2秒",2000+"");
//        send("延迟消息睡5秒",5000+"");
//        return "ok";
//    }
//
//    private void send(String msg, String delayTime){
//        //将消息携带路由键值
//        rabbitTemplate.convertAndSend(DelayQueueRabbitConfig.ORDER_EXCHANGE, DelayQueueRabbitConfig.ORDER_ROUTING_KEY,
//                msg,message->{
//                    message.getMessageProperties().setExpiration(delayTime);
//                    return message;
//                });
//    }
//
//}
